package com.hx.dc.controllor;

import com.hx.dc.entity.StoreTable;
import com.hx.dc.entity.TableUser;
import com.hx.dc.service.StoreTableService;
import com.hx.dc.util.ewm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * Created by Mr.Lee on 2019/2/14.
 */
@Controller
@RequestMapping("storetable")
public class StoreTableAction extends BaseAction{

    @Autowired
    private  StoreTableService storeTableService;

    @RequestMapping(value = "/selectPage")
    @ResponseBody
    public Object selectPage(StoreTable storeTable, Integer page, Integer rows){

        System.out.println("page:" + page + ",rows:" + rows);

        return this.getPage(storeTableService.selectPage(storeTable,page,rows));
    }

    @RequestMapping(value = "/addTable")
    @ResponseBody
    public Object addTable(StoreTable storeTable){
        ewm.getEwm(storeTable);
        System.out.println("输入信息"+storeTable);
        int i = storeTableService.insert(storeTable);
        return i;
    }

    @RequestMapping(value = "/updateTable")
    @ResponseBody
    public Object updateTable(StoreTable storeTable){
        System.out.println("修改信息"+storeTable);
        return storeTableService.update(storeTable);
    }
    @RequestMapping(value = "/updateDisable")
    @ResponseBody
    public Object updateDisable(StoreTable storeTable){
        System.out.println("修改信息"+storeTable);
        return storeTableService.updateDisable(storeTable);
    }
    @RequestMapping(value = "/updateAble")
    @ResponseBody
    public Object updateAble(StoreTable storeTable){
        System.out.println("修改信息"+storeTable);
        return storeTableService.updateAble(storeTable);
    }

    @RequestMapping(value = "/select")
    @ResponseBody
    public Object select(HttpServletRequest request, StoreTable storeTable){
        System.out.println("输入信息"+storeTable);

        /*storeTable.setTableNum(storeTableService.select(storeTable).getTableNum());*/

       /*request.setAttribute("tableMsg",storeTableService.select(storeTable).getTableNum());
        request.setAttribute("tableMsg",storeTableService.select(storeTable).getTableName());*/
       List list = storeTableService.selectList(storeTable);

        return list;
    }

    @RequestMapping(value = "/selectName")
    @ResponseBody
    public Object selectName(HttpServletRequest request, StoreTable storeTable){
        System.out.println("输入信息"+storeTable);

        /*storeTable.setTableNum(storeTableService.select(storeTable).getTableNum());*/

       /*request.setAttribute("tableMsg",storeTableService.select(storeTable).getTableNum());
        request.setAttribute("tableMsg",storeTableService.select(storeTable).getTableName());*/
        List list = storeTableService.selectName(storeTable);

        return list;
    }

    @RequestMapping(value = "/search")
    @ResponseBody
    public Object search(StoreTable storeTable){
        System.out.println("输入信息"+storeTable);
        List list = storeTableService.search(storeTable);
        return list;
    }

    @RequestMapping(value = "/bookTable")
    @ResponseBody
    public Object bookTable(StoreTable storeTable){
        System.out.println("输入信息"+storeTable);
        return storeTableService.insert(storeTable);
    }

}
